

import 'package:flutter/material.dart';
import 'package:teststudy/sport/ArmBar.dart';
import 'package:teststudy/sport/Rope.dart';
import 'package:teststudy/sport/Step.dart';

import 'package:teststudy/sport/WeHoop.dart';


class FirthPage extends StatefulWidget {
  FirthPage({Key key}) : super(key: key);

  @override
  _FirthPageState createState() => _FirthPageState();
}

class _FirthPageState extends State<FirthPage>  with SingleTickerProviderStateMixin,AutomaticKeepAliveClientMixin {

     
    List<Tab> _tabs = [
      Tab(text: "步行",icon: Icon(Icons.directions_run),),
      Tab(text:'呼啦圈',icon: Icon(Icons.accessible_forward),),
      Tab(text:'臂力棒',icon: Icon(Icons.fitness_center),),
      Tab(text:'跳绳',icon: Icon(Icons.gesture),),

    ];

   final List<Widget> _pages = [
    StepPage(),
    WeHoop(),
    Rope(),
    ArmBar(),
  ];
  TabController _controller;
  @override
  void initState() { 
    super.initState();
     _controller = TabController(length: _tabs.length, vsync: this);
    debugPrint("first");
  }
  @override
  Widget build(BuildContext context) {
    super.build(context);
    Size mSize = MediaQuery.of(context).size;
    print(mSize);
    final screenWidth = mSize.width;
    
    return Container(
         width: screenWidth,
         alignment:Alignment(0, 0),
         color: Colors.black26,
          child:Column(
            children: <Widget>[
              Container(
                width: screenWidth,
                height: 80,
                child: TabBar(tabs:_tabs,controller: _controller),
              ),
              Expanded(
                child:Container(
                color: Colors.red,
                child: TabBarView(
                  controller: _controller,
                  children: _pages,
                ),
                )
               
              ),
              
            ],
          ) ,

    );
  }

  @override
  bool get wantKeepAlive=>true;
 
}

